package ihm.overlays;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridLayout;

public class FriendOverlay extends Composite {

	private Button returnButton;
	private Label birthDateTextArea;
	private Label addressTextArea;
	private Label eMailTextArea;
	private Label phoneNumberTextArea;
	private Label hobbiesTextArea;
	private Label portTextArea;
	private Label picture;
	private Label usernameTextArea;

	private static final String USERNAME_CAPTION = "Name: ";
	private static final String RETURNBUTTON_CAPTION = "Return to friend list";

	public FriendOverlay(Composite father) {
		super(father, SWT.NONE);
		setLayout(new GridLayout(1, true));

		returnButton = new Button(this, SWT.FLAT);
		returnButton.setText(RETURNBUTTON_CAPTION);

		picture = new Label(this, SWT.NONE);
		usernameTextArea = new Label(this, SWT.NONE);
		birthDateTextArea = new Label(this, SWT.NONE);
		addressTextArea = new Label(this, SWT.NONE);
		eMailTextArea = new Label(this, SWT.NONE);
		phoneNumberTextArea = new Label(this, SWT.NONE);
		hobbiesTextArea = new Label(this, SWT.NONE);
		portTextArea = new Label(this, SWT.NONE);
	}

	/**
	 * add a listener to the return button of the ui.
	 * @param listener to add.
	 */
	public void addReturnButtonSelectionListener(SelectionListener listener)
	{
		returnButton.addSelectionListener(listener);
	}
	
	public void setBirthDate(String birthDate) {
		this.birthDateTextArea.setText(birthDate);
	}

	public void setAddress(String address) {
		this.addressTextArea.setText(address);
	}

	public void setEMail(String eMail) {
		this.eMailTextArea.setText(eMail);
	}

	public void setPicture(Image img) {
		this.picture.setImage(img);
	}

	public void setUserName(String userName) {
		this.usernameTextArea.setText(USERNAME_CAPTION + userName);
	}

	public void setHobbies(String hobbies) {
		this.hobbiesTextArea.setText(hobbies);
	}

	public void setPort(String port) {
		this.portTextArea.setText(port);
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumberTextArea.setText(phoneNumber);
	}

}
